<template>
  <BasicModal :title="title" :width="500" v-bind="$attrs" @ok="methods.handleSubmit" @register="registerModel" :useWrapper="true" destroyOnClose>
    <BasicForm @register="registerForm" />
  </BasicModal>
</template>
<script setup lang="ts">
  import ApiV1 from '@/views/common/operate/ApiV1';
  import BasicForm from '@/components/Form/src/BasicForm.vue';
  import BasicModal from '@/components/Modal/src/BasicModal.vue';
  import { apiGetUnitDetailsPath, apiPostUnitAdd, apiPostUnitUpdatePath } from '@/api/http/system/auxiliary/unit/unit.api';
  import { useUnitUpdateSchemaForm } from '@/api/http/system/auxiliary/unit/unit.data';

  const emit = defineEmits(['success', 'register']);
  const { registerForm, registerModel, methods, title } = ApiV1.useHandle(emit, {
    formProps: { schemas: useUnitUpdateSchemaForm(), baseColProps: { span: 24 } },
    title: '商品单位',
    details: apiGetUnitDetailsPath,
    saveFn: apiPostUnitAdd,
    updateFn: apiPostUnitUpdatePath,
  });
</script>
